﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BusinessObjects.BO_GetObjects;
using DigiLib;
using System.Security.Cryptography;

public partial class controls_admin_FriviewSiteAdd : Admin_Controls_Base
{
    protected void Page_Load(object sender, EventArgs e)
    {
        base.removeHGC(divMessage);
        if (!IsPostBack)
        {
            try
            {
                base.bindDDL(ddlCategories, BO_portal_categories.SelectByParent(64, 1), "FULL_CATEGORY_NAME", "CATEGORY_ID");
            }
            catch (Exception ex)
            {
                divMessage.InnerHtml = MessageBox.Error("Lỗi", "Phát sinh lỗi như sau: " + ex.Message);
            }
        }
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            string multi = string.Empty;
            string filename = base.Upload("website", String.Empty, fulTHUMB_IMG, divMessage, false);
            int category_id = Convert.ToInt32(ddlCategories.SelectedValue);
            int status = 1;
            string tags = string.Empty;
            string title = txtFULL_ARTICLE_TITLE.Text.Trim();
            string full_article_description = string.Empty;
            string details = string.Empty;
            bool displayOnHome = true;
            bool hot = false;
            int sort_display = Convert.ToInt32(txtOrder.Text.Trim());
            string m_key = string.Empty;
            string m_desc = string.Empty;
            string strResult = BO_portal_articles.Insert(category_id, 1, string.Empty,
                             multi, filename, txtLink.Text.Trim(), string.Empty, title, string.Empty, string.Empty
                             , string.Empty, full_article_description, string.Empty,
                             details, string.Empty, m_key, m_desc, tags, 0,
                            0, 0, 0, displayOnHome, hot, sort_display, sort_display, DateTime.Now, DateTime.Now,
                            Administrator.USER_NAME, DateTime.Now, Administrator.USER_NAME, DateTime.Now, Administrator.USER_NAME, status);
            if (strResult != "0")
            {
                divMessage.InnerHtml = MessageBox.Success("Thông Báo", "Thực hiện thành công!");
                Clear(this.Controls);
            }
            else
                divMessage.InnerHtml = MessageBox.Error("Lỗi", "Có lỗi trong quá trình xử lý! ");
        }
        catch (Exception ex)
        {
            divMessage.InnerHtml = MessageBox.Error("Lỗi", "Phát sinh lỗi như sau: " + ex.Message);
        }
    }
}
